package com.appspot.smartgan.util;

import java.io.Serializable;


/**
 * The class represents a child.
 * <p>
 * This class is used to transfer child information
 * between different application activities.
 * @author Dor Mesica
 */
@SuppressWarnings("serial")
public class Child implements Serializable {

	// final fields
	public static final String ARRIVED = "Arrived";
	public static final String NOT_ARRIVED = "Not arrived";
	
	// attributes of the class:
	private String id;			// the id of the child on the database
	private String school;		// object of class school represents the child's school
	private boolean hasArrived;	// has the kid arrived at school taken from database
	private String name;		// child's name
	
	/**
	 * Creates a new instance of the class Child
	 * with the given ID, school and name.
	 * @param id The child's ID number.
	 * @param school The child's school.
	 * @param name The name of the child.
	 * @param hasArrived true if the child arrived at school
	 * 		 otherwise false
	 */
	public Child(String id, String school, String name, boolean hasArrived) {
		this.id = id;
		this.school = school;
		this.name = name;
		this.hasArrived = hasArrived;
	}
	
	/**
	 * Creates a new instance of the class Child
	 * with the given ID, school and name.
	 * @param id The child's ID number.
	 * @param school The child's school.
	 * @param name The name of the child.
	 * @param hasArrived hasArrived true if the child arrived at school
	 * 		 otherwise false
	 * @throws IDException An exception is thrown in case an
	 * 			Illegal id number was given
	 */
	public Child(String id, String school, String name) {
		this.id = id;
		this.school = school;
		this.name = name;
		this.hasArrived = false;
	}

	/**
	 * Returns the ID number of the current child.
	 * @return The ID number of the child
	 */
	public String getId() {
		return id.toString();
	}
	
	public String getSchoolId() {
		return school;
	}
	
	/**
	 * Returns the current child's name.
	 * @return The name of the child
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Return true iff the child has arrived at school;
	 * @return True if arrived otherwise returns false
	 */
	public boolean hasArrived() {
		return hasArrived;
	}
	
	public void setAttendance(boolean hasArrived) {
		this.hasArrived = hasArrived;
	}
	
	public void setSchool(String school) {
		this.school = school;
	}
	
	@Override
	public Child clone() {
		return new Child(new String(id), new String(school),
				new String(name), hasArrived);
	}
}
